home *** CD-ROM | disk | FTP | other *** search
/ Stolen Data 3 / Stolen Data 3.adf / SOURCE / Scroller3.s < prev    next >
Text File  |  1988-12-31  |  8KB  |  272 lines

  1. *****************************************************************************
  2. ;                         STOLEN DATA Issue #3
  3. ;                         ~~~~~~~~~~~~~~~~~~~~
  4. ;   Non-double buffered hardware scroller
  5. ;
  6. ;   Copyright ANARCHY 1990
  7. ;
  8. ;   Written on 3.6.90 by Kreator of ANARCHY
  9. ;
  10. ; Probably the most useful scroller in general use as it allows variable
  11. ; speeds, and instant scroller controllables.
  12. ;
  13. ;  General notes - At all times (unless specified) a6 points to the custom
  14. ; chip registers ($dff000) and a5 points to the list of variables.This allows
  15. ; indirect addressing modes to be used, which are much faster than absolute
  16. ; addressing and consume less memory. If these registers are needed in the
  17. ; course of a routine simply stick them on the stack, and pop them back off
  18. ; later.
  19. *****************************************************************************
  20.  
  21.     Incdir    DF1:
  22.     Include    Source/NewCustomReg    ; Custom register label equates
  23.     Section    Scroller,Code_c        ; Assemble into chip mem if > ½ meg
  24.  
  25. TEST        = 1        ; Set this if you are only testing the menu
  26.                 ; as it will then return to DEVPAC
  27.  
  28. Trap_vec0    = $80
  29. Execbase    = $4
  30. Oldopen        = -$198
  31. Screen        = $70000
  32. Scrollspeed     = 6        ; Alter this for different speeds, you can
  33.                 ; change the variable speed during the demo
  34.                 ; for alterable speeds.
  35.  
  36.     Move.l    #Start,$80.w    ; Trap vector 0
  37.     Trap    #0        ; Execute trap 0 to give full control of the
  38.     Rts            ; 68000, needs an RTE to return.
  39.  
  40. Start
  41.     Bsr    Killsys        ; Disable the operating system
  42.     Bsr    Setup        ; Setup the demo
  43.     Bsr    Main        ; Now run the main demo routines
  44.     Bsr    Sysreturn    ; Return the system to its original state
  45.     Moveq.l    #0,d0        ; No errors !! A number of people neglect to
  46.                 ; do this, and that causes batch files (such
  47.                 ; as the startup sequence) to bomb out.
  48.     Rte        ; Return from exception ie. to the instruction after
  49.             ; the TRAP #0 call.
  50.  
  51. *****************************************************************************
  52. ;Killsys - Disable operating system and interrupts
  53. *****************************************************************************
  54. Killsys
  55.     Move.l    $4.w,a6        ; Execbase vector
  56.     Lea    Gfxname(pc),a1    ; Pointer to "graphics.library" into a1
  57.     Jsr    Oldopen(a6)    ; Open this library
  58.     Lea    Variables,a5    ; Get a pointer to the variable space
  59.     Lea    $dff000,a6    ; Pointer to custom chips
  60.     Move.l    d0,a0        ; Address of the graphics library
  61.     Move.l    38(a0),Sys_copl(a5)    ; Remember the System copperlist
  62.     Move    Intenar(a6),Int_set(a5)    ; System interrupts
  63.     Move    #$7fff,Intena(a6)    ; Now switch off all interrupts
  64.     Move.l    $6c.w,Vbl_vec(a5)    ; System vertical blanking int.
  65.     Move    Dmaconr(a6),Dma_set(a5)    ; System DMA
  66.     Move    #$7fff,Dmacon(a6)    ; Clear all DMA
  67.     Move    #$87c0,Dmacon(a6)    ; Now set the required DMA channels
  68.     Rts
  69.  
  70. Gfxname        Dc.b "graphics.library",0
  71.     Even
  72. *****************************************************************************
  73. ;Sysreturn - Re-enable operating system and interrupts
  74. *****************************************************************************
  75. Sysreturn
  76.     Move    #$7fff,Intena(a6)    ; Clear all interrupts
  77.     Move.l    Vbl_vec(a5),$6c.w    ; Restore VBL interrupt
  78.     Move    Int_set(a5),d0
  79.     Or    #$c000,d0
  80.     Move    d0,Intena(a6)        ; Restore system interrupts
  81.     Move    #$7fff,Dmacon(a6)
  82.     Move    Dma_set(a5),d0
  83.     Or    #$8200,d0
  84.     Move    d0,Dmacon(a6)        ; Restore system DMA
  85.     Move.l    Sys_copl(a5),Cop1lch(a6)    ; Restore system copperlist
  86.     Clr    Copjmp1(a6)
  87.     Rts
  88. *****************************************************************************
  89. ;Setup - Setup the menu system
  90. *****************************************************************************
  91. Setup
  92.  
  93. ;-- Remove the sprite data (prevents sprite streaks down the screen)
  94.  
  95.     Lea    Spr0data(a6),a0
  96.     Moveq    #7,d0
  97. Clop
  98.     Clr.l    (a0)
  99.     Addq.l    #8,a0
  100.     Dbf    d0,Clop
  101.  
  102. ;-- Clear the scroll area
  103.  
  104.     Lea    Screen,a0
  105.     Move    #$bff,d0
  106. Clear_scroll
  107.     Clr.l    (a0)+
  108.     Dbf    d0,Clear_scroll
  109.  
  110. ;-- Initialise some variables
  111.  
  112.     Move.l    #Scrolltext,Textpt(a5)    ; Initialise the scrolltext
  113.     Move.l    #Clstart,Cop1lch(a6)    ; Init. our own copperlist
  114.     Clr    Copjmp1(a6)
  115.     Move    #Scrollspeed,Speed(a5)    
  116.     Rts
  117.  
  118. *****************************************************************************
  119. ; Main - Central demo calling routine + mouse button check
  120. *****************************************************************************
  121. Main
  122.     Move.l    Vposr(a6),d0
  123.     And.l    #$1ff00,d0
  124.     Cmp.l    #$00100,d0    ; Wait for vertical position 1
  125.     Bne.s    Main
  126.  
  127.     Bsr    Scroller    ; Jump to the scroll routine
  128.     Move    #$200,d0
  129. .Loop
  130.     Dbf    d0,.Loop
  131.  
  132.     Btst    #6,$bfe001    ; Check the left mouse button
  133.     Bne.s    Main
  134.  
  135.     Rts
  136. *****************************************************************************
  137. ; Scroller - This scroller is 46 bytes across all of which are displayed
  138. *****************************************************************************
  139. Scroller
  140.     Move    Count(a5),d7
  141.     Sub    Speed(a5),d7        ; Counter tells us if we need a
  142.     Bpl    Nonewchar        ; new character
  143.  
  144.     Move.l    #-1,Bltafwm(a6)
  145.     Move.l    #$9f00000,Bltcon0(a6)    ; Shift the scroll area left 2
  146.     Clr.l    Bltamod(a6)        ; pixels
  147.     Move.l    #Screen+2,Bltapth(a6)
  148.     Move.l    #Screen,Bltdpth(a6)    ; Careful, here as the shift operation
  149.                     ; obliterates the word Screen-2
  150.     Move    #16*64+23,Bltsize(a6)    
  151.     Bsr    Blitwait
  152.  
  153.  
  154.     Move.l    Textpt(a5),a0
  155.     Moveq    #0,d0
  156. Read_char
  157.     Move.b    (a0)+,d0        ; Read a char. from scrolltext
  158.     Bne.s    Not_null        ; If zero, reset text pointer
  159.     Lea    Scrolltext(pc),a0
  160.     Bra.s    Read_char        ; Read the first character
  161. Not_null
  162.     Cmp    #$20,d0        ; Check for control codes, and convert to
  163.     Bgt.s    Not_control    ; spaces
  164.     Moveq    #$20,d0
  165. Not_control
  166.     Cmp    #$5b,d0        ; Lower case characters, convert to uppercase
  167.     Blt.s    Not_lower
  168.     Sub    #$20,d0
  169. Not_lower
  170.     Sub    #$20,d0
  171.     Add    d0,d0
  172.     Lea    Charpos(pc),a1
  173.     Move    (a1,d0),d0
  174.     Lea    Font(pc),a1
  175.     Lea    (a1,d0),a1
  176.  
  177.     Move.l    a1,Bltapth(a6)    ; Plot the new character
  178.     Lea    Screen+$2c,a2    ; Plot into the last position on the line
  179.     Move.l    a2,Bltdpth(a6)
  180.     Move.l    #$0026002c,Bltamod(a6)
  181.     Move.l    #$09f00000,Bltcon0(a6)
  182.     Move    #16*64+1,Bltsize(a6)
  183.     Move.l    a0,Textpt(a5)
  184.     Add    #16,d7
  185. Nonewchar
  186.     Move    d7,Count(a5)
  187.     And    #$f,d7
  188.     Move    d7,Pixelscroll+2
  189.     Rts
  190.  
  191. Blitwait
  192.     Btst    #14,Dmaconr(a6)
  193.     Bne.s    Blitwait
  194.     Rts
  195.  
  196. *****************************************************************************
  197. ; Copperlists
  198. *****************************************************************************
  199. Clstart
  200.     Wait    0,20
  201.     Mov    0,Color00
  202.     Mov    $80f,Color01
  203.     Mov    $1a64,Diwstrt
  204.     Mov    $39d1,Diwstop
  205.     Mov    $0028,Ddfstrt
  206.     Mov    $00d8,Ddfstop
  207.     Mov    0,Bplcon0
  208. Pixelscroll
  209.     Mov    0,Bplcon1
  210.     Mov    0,Bplcon2
  211.     Mov    0,Bpl1mod
  212.     Mov    0,Bpl2mod
  213.  
  214.     Mov    0,Bpl1ptl
  215.     Mov    7,Bpl1pth
  216.     Wait    0,$90
  217.     Mov    $1200,Bplcon0
  218.  
  219.     Wait    0,$a0
  220.     Mov    0,Bplcon0
  221.  
  222.     Wait    $fe,$ff
  223. *****************************************************************************
  224. ; Binaries
  225. *****************************************************************************
  226.  
  227. Scrolltext
  228.     Dc.b    "copyright anarchy 1990, coded of course by kreator"
  229.     Dc.b    "  this scroller is probably the most useful because"
  230.     Dc.b    " it allows variable speeds to be employed very easily"
  231.     Dc.b    " amongst other advantages           "
  232.     Dc.b    0
  233.     Even
  234.  
  235. Font
  236.     Incbin    Binary/Bubble.font    ; This font was drawn by KREATOR
  237.                     ; so credit me if you use it
  238.  
  239. ; The following table is used to calculate a pointer to the required
  240. ; character and in general must be created by hand. Some coders advocate a
  241. ; different approach, which is to have all your characters stacked on top
  242. ; of each other and then the pointers are very easy to calculate with a
  243. ; multiply. I still prefer this method myself.
  244.  
  245. Charpos    Dc.w    $0000,$0002,$0004,$0006,$0008,$000a,$000c,$000e ; !"#$%&'
  246.     Dc.w    $0010,$0012,$0014,$0016,$0018,$001a,$001c,$001e ;()*+,-./
  247.     Dc.w    $0020,$0022,$0024,$0026,$0280,$0282,$0284,$0286 ;01234567
  248.     Dc.w    $0288,$028a,$028c,$028e,$0290,$0292,$0294,$0296 ;89:;<=>?
  249.     Dc.w    $0298,$029a,$029c,$029e,$02a0,$02a2,$02a4,$02a6 ;@ADCDEFG
  250.     Dc.w    $0500,$0502,$0504,$0506,$0508,$050a,$050c,$050e ;HIJKLMNO
  251.     Dc.w    $0510,$0512,$0514,$0516,$0518,$051a,$051c,$051e ;PQRSTUVW
  252.     Dc.w    $0520,$0522,$0524,$0526                         ;XYZ[\]^_
  253.  
  254. *****************************************************************************
  255. ;   Variables
  256. *****************************************************************************
  257.  
  258.     Rsreset
  259. Int_set        Rs.w 1    ; System interrupts
  260. Dma_set        Rs.w 1    ; System DMA channels
  261. Sys_copl    Rs.l 1    ;  ""    copperlist
  262. Vbl_vec        Rs.l 1    ;  ""    vertical blanking interrupt
  263. Count        Rs.w 1    
  264. Textpt        Rs.l 1    ; Pointer to the scrolltext
  265. Speed        Rs.w 1    : Scroller speed
  266. Varisize    Rs.b 0    ; Simply used to determine how much space is needed
  267.             ; for the variable list
  268.  
  269. Variables    Dcb.b Varisize    ; Reserve space for the variables
  270.  
  271.  
  272.